#ifndef SIMPLEKEY_H_
#define SIMPLEKEY_H_

#include <sstream>

#include "../serializable.h"

template<typename Type>
class TypeKey : public Serializable {
    public:

        TypeKey() { }
        TypeKey(Type id) : id(id) {}

        void set(Type id) {
            this->id = id;
        }
        Type get() {
            return id;
        }
        virtual void read(BinaryStream& in) {
            id = in.readPrimitive<Type>();
        }
        virtual void write(BinaryStream& out) {
            out.writePrimitive<Type>(id);
        }

        bool operator==(const TypeKey<Type>& that) const { return id == that.id; }
        bool operator!=(const TypeKey<Type>& that) const { return id != that.id; }
        bool operator<(const TypeKey<Type>& that) const { return id < that.id; }
        bool operator>(const TypeKey<Type>& that) const { return id > that.id; }
        bool operator<=(const TypeKey<Type>& that) const { return id >= that.id; }
        bool operator>=(const TypeKey<Type>& that) const { return id >= that.id; }

        virtual std::string toString(){
            std::stringstream sout;
            sout << id;
            return sout.str();
        }
    protected:
        Type id;
};

#endif /* SIMPLEKEY_H_ */
